<?php

namespace App\Http\Resources\Activity\Merchant;

use App\Http\Resources\BaseResource;
use App\Models\Activity\ShopOrderActivityModel;
use Carbon\Carbon;
use Illuminate\Http\Request;

class ShopOrderActivityDetailResource extends BaseResource
{

    /**
     * @param Request $request
     * @return array
     */
    public function toArray($request): array
    {
        return [
            "id"             => $this->id,
            "type"           => $this->type,
            "typeText"       => ShopOrderActivityModel::TYPE_TEXT[$this->type] ?? "-",
            "name"           => $this->name,
            "expireType"     => $this->expireType,
            "expireTypeText" => ShopOrderActivityModel::EXPIRE_TYPE_TEXT[$this->expireType] ?? "-",
            "startTime"      => $this->startTime > 0 ? Carbon::createFromTimestamp($this->startTime)
                                                             ->format("Y-m-d H:i:s") : "-",
            "endTime"        => $this->startTime > 0 ? Carbon::createFromTimestamp($this->endTime)
                                                             ->format("Y-m-d H:i:s") : "-",
            "intro"          => $this->intro,
            "title"          => $this->title,
            "detail"         => $this->detail,
            "shopType"       => $this->shopType,
            "shopTypeText"   => ShopOrderActivityModel::SHOP_TYPE_TEXT[$this->shopType] ?? "-",
            "remark"         => $this->remark,
            "status"         => $this->status,
            "statusText"     => ShopOrderActivityModel::STATUS_TEXT[$this->status] ?? "-",
            "createdAtText"  => $this->createdAt->format("Y-m-d H:i:s"),
            "updatedAtText"  => $this->updatedAt->format("Y-m-d H:i:s"),
        ];
    }
}
